package com.woniuxueyuan.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseData<T> {
    private Integer code;
    private T data;
    private String msg;



    /**
     * 封装一个成功方法(需要带参数)
     */
    public static <T> ResponseData ok(T data){
        return  new ResponseData(ResponseEnum.SUCCESS.getCode(),data ,"操作成功");
    }
    public static  ResponseData ok(){
        return  new ResponseData( ResponseEnum.SUCCESS.getCode(),null ,"操作成功");
    }

    /**
     * 封装一个失败方法（业务方面异常）
     * 1.系统业务异常返回的情况好多 一个异常对应一个code码
     */
    public static  ResponseData fail(ResponseEnum responseEnum){
        return  new ResponseData(responseEnum.getCode(),null,"操作失败");
    }
}